package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.OrderService;
import com.itheima.reggie.OrdersService;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;

    //结账
    @PostMapping("/order/submit")
    public ResultInfo post(@RequestBody Order order) {
        orderService.post(order);
        return ResultInfo.success(null);
    }


    //查看最新订单
    @GetMapping("/order/userPage")
    public ResultInfo findById(@RequestParam(defaultValue = "1") Integer page,
                               @RequestParam(defaultValue = "5") Integer pageSize){
       Page<Order> order1= orderService.findById(page,pageSize);
       return ResultInfo.success(order1);
    }
}